

package com.example.administrator.caigou51.recyclerCard.cardView;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.example.administrator.caigou51.R;
import com.example.administrator.caigou51.activity.GoodsListActivity;
import com.example.administrator.caigou51.global.App;
import com.example.administrator.caigou51.recyclerCard.basic.CardItemView;
import com.example.administrator.caigou51.recyclerCard.card.OneGoodsCard;
import com.example.administrator.caigou51.util.ImageUtil;

import java.io.Serializable;


public class OneGoodsCardView extends CardItemView<OneGoodsCard> {
 	private Context mContext;
    private ImageView imageViewGoods;
    private RelativeLayout relativeLayoutGuangDong;
    public OneGoodsCardView(Context context) {
        super(context);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public OneGoodsCardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public OneGoodsCardView(Context context,
                                    AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext=context;
        // TODO Auto-generated constructor stub
    }
    @Override
    public void build(final OneGoodsCard card) {
        // TODO Auto-generated method stub
        super.build(card);
        imageViewGoods=(ImageView)findViewById(R.id.imageViewGoods);
        relativeLayoutGuangDong= (RelativeLayout) findViewById(R.id.relativeLayoutGuangDong);
        App.displayImageHttpOrFile(card.getGoodsEntity().getThumb(),imageViewGoods, ImageUtil.OptionsActivity());

        setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent2=new Intent(mContext, GoodsListActivity.class);
                        intent2.putExtra(GoodsListActivity.TagList, (Serializable) card.getGoodsEntityList());

                        mContext.startActivity(intent2);
                    }
                });
            }
        });

        //(1代表全国，2代表限广东）
        if ("2".equals(card.getGoodsEntity().getSale_range())) {
            relativeLayoutGuangDong.setVisibility(View.VISIBLE);
        }else
        {
            relativeLayoutGuangDong.setVisibility(View.GONE);
        }
    }
}
